//package com.ruoyi.web.config;
//
//import com.aliyun.openservices.ons.api.MessageListener;
//import com.aliyun.openservices.ons.api.PropertyKeyConst;
//import com.aliyun.openservices.ons.api.bean.ConsumerBean;
//import com.aliyun.openservices.ons.api.bean.Subscription;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//import java.util.Map;
//import java.util.Properties;
//
///**
// * 阿里云MQ-订阅消费者监听
// *
// * @author chen
// */
//@Configuration
//public class ConsumerClient {
//
//    @Autowired
//    private AliyunMQConfig aliyunMQConfig;
//
//    @Autowired
//    @Qualifier("smsTopicProperties")
//    private AliyunMQConfig.TopicProperties smsTopicProperties;
//
//    @Autowired
//    private SmsMqMessageListener smsMqMessageListener;
//
//    @Bean(initMethod = "start", destroyMethod = "shutdown")
//    public ConsumerBean messageBuildConsumer() {
//        ConsumerBean consumerBean = new ConsumerBean();
//        //配置文件
//        Properties properties = aliyunMQConfig.getMqProperties();
//        //消费者
//        properties.setProperty(PropertyKeyConst.GROUP_ID, smsTopicProperties.getGroupId());
//        //设置消费者线程数为20个（默认20）
//        properties.setProperty(PropertyKeyConst.ConsumeThreadNums, "20");
//        consumerBean.setProperties(properties);
//        //订阅消息
//        Map<Subscription, MessageListener> subscriptionTable = new HashMap<>();
//        //订阅短信消息
//        Subscription smsSubscription = new Subscription();
//        smsSubscription.setTopic(smsTopicProperties.getTopic());
//        smsSubscription.setExpression(smsTopicProperties.getTag());
//        subscriptionTable.put(smsSubscription, smsMqMessageListener);
//
//        consumerBean.setSubscriptionTable(subscriptionTable);
//        return consumerBean;
//    }
//
//}
